package com.tanhua.api.db;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.api.db.BlackListApi;
import com.tanhua.domain.db.BlackList;
import com.tanhua.domain.db.UserInfo;
import com.tanhua.mapper.BlackListMapper;
import com.tanhua.mapper.UserInfoMapper;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
//黑名单
@Service
public class BlackListApiImpl implements BlackListApi {
    @Autowired
    private BlackListMapper blackListMapper;
    @Autowired
    private UserInfoMapper userInfoMapper;


    @Override
    public IPage<UserInfo> findBlackList(Long userId, Integer pageNum, Integer pageSize) {
        //开启分页功能
        Page page =new Page<UserInfo>(pageNum,pageSize);
        //执行sql 语句
        return userInfoMapper.findBlackList(page,userId);

    }

    @Override
    public void deleteBlack(Long userId, Long blackUserId) {
        QueryWrapper<BlackList> qw = new QueryWrapper<>();
        qw.eq("user_id", userId);
        qw.eq("black_user_id", blackUserId);
        blackListMapper.delete(qw);

    }
}
